<template>
	<view class="bods">
		<view class="cont">
			<view class="or_tsbs">
				<u-tabs lineWidth="40" :activeStyle="{
						color: '#3E86F9',
						fontWeight: 'bold',
						transform: 'scale(1)'
					}" :inactiveStyle="{
						color: '#999999',
						transform: 'scale(.9)',
						fontWeight: 'bold',
						}" itemStyle="padding-left: 20rpx; padding-right: 20rpx; height: 100rpx;" lineHeight='3' :scrollable='false'
					:list="list1" :current='tbs_num' @click="checkbtn"></u-tabs>
			</view>

			<!-- //数据列表 -->
			<view>
				<!-- 列表1 -->
				<view v-if="show_list[0]">
					<myTodolist ref="mytodolist" />
				</view>
				<!-- 列表2 -->
				<view v-if="show_list[1]" >
					<mydonelist ref="mydonelist" />
				</view>
				<!-- 列表3 -->
				<view v-if="show_list[2]">
					<todoCirculatedList ref="todoCirculatedList" />
				</view>
				<!-- 列表4 -->
				<view v-if="show_list[3]">
					<mydraftList ref="mydraftList"/>
				</view>
				<!-- 底部 -->
			</view>
		</view>

	</view>
</template>
<script>
	import myTodolist from '@/workspaces/views/myEvent/myTodolist.vue'
	import mydonelist from '@/workspaces/views/myEvent/mydonelist.vue'
	import todoCirculatedList from '@/workspaces/views/myEvent/todoCirculatedList.vue'
	import mydraftList from '@/workspaces/views/myEvent/mydraftList.vue'
	export default {
		components: {
			myTodolist,
			mydonelist,
			todoCirculatedList,
			mydraftList
		},
		data() {
			return {
				list1: [{
					name: '我的待办',
				}, {
					name: '我发起的',
				}, {
					name: '我审阅的'
				}, {
					name: '我暂存的'
				}],

				tbs_num: 0, //控制第几个tabs
				show_list: [true, false, false, false], //控制显示隐藏
				//渲染数据
				timersort: true, //正序倒序
			}
		},
		onload() {
			let that = this
			let f2bpmAuthor = JSON.parse(sessionStorage.getItem('f2bpmAuthor'))
			if (!f2bpmAuthor) {
				setTimeout(function() {
					uni.reLaunch({
						url: './login'
					})
				}, 200)
				return false
			}
		},
		onShow(e) {
			var author= sessionStorage.getItem("f2bpmAuthor");
			if(!author){
				this.$api.showTip("用户过期，请重新登录");
				setTimeout(()=>{
					uni.reLaunch({
						url: '/workspaces/views/login/login'
					});
				},2000)
			} else {
				this.onderon()
			}
		},
		onPullDownRefresh: function() {
			//下拉刷新
			var that = this;
			window.location.reload();
			uni.stopPullDownRefresh();
		},
		methods: {
			onReachBottom: function() {
				if (this.tbs_num === 0) {
					this.$refs.mytodolist.layz()
					return false
				} else if(this.tbs_num === 1) {
					this.$refs.mydonelist.layz()
					return false
				}
			},
			onderon() {
				this.tbs_num = uni.getStorageSync('currentIndex')
				for (let j = 0; j < 4; j++) {
					if (this.tbs_num > j || this.tbs_num < j) {
						this.show_list[this.tbs_num] = true
						this.show_list[j] = false
					}
				}
				// uni.removeStorageSync('currentIndex')
			},
			open() {
				console.log('open');
			},
			close() {
				this.show = false
				console.log('close');
			},
			// 切换list列表
			checkbtn(item) {
				// console.log(item)
				for (let i = 0; i < 4; i++) {
					if (item.index > i || item.index < i) {
						this.$set(this.show_list, item.index, true)
						this.tbs_num = item.index
						this.$set(this.show_list, i, false)
					}
				}
				uni.setStorageSync('currentIndex', item.index)
			},
		},

	}
</script>

<style lang="scss" scoped>
	view {
		font-family: pf
	}

	.bods {
		background-color: rgb(248, 249, 251);
		width: 100%;
	}

	.cont {
		width: 100%;
		background-color: white;
	}

	.or_tsbs {
		position: fixed;
		top: 0;
		z-index: 4;
		width: 100%;
		background-color: white;
	}
</style>
